#!/bin/bash

. /etc/rc.d/functions_x

echo '<JWM>'
while read a b c d
do
	PARTITION=$d
	DRIVE=$(fx_get_drvname $PARTITION)
    case $PARTITION in
    sd[a-z][0-9]*|nvme[0-9]n[0-9]p[0-9]*)
        #[ $c -le 1 ] && continue # extd partition
        [ "$(grep "$DRIVE" /root/.usb-drive-log-probedisk)" ] && MEDIA="usbdrv" || MEDIA="drive" 
        FILESYSTEM=$(guess_fstype /dev/$PARTITION 2>/dev/null)
        [ "$FILESYSTEM" = 'swap' -o "$FILESYSTEM" = 'unknown' ] && continue
        INFO="`cat /sys/block/$DRIVE/device/model`"
        ;;
    scd*|sr*)
        if [ -d "$HOME/.pup_event/drive_${PARTITION}" ];then
            MEDIA="optical"
            FILESYSTEM="iso9660"
            INFO=""
        else
            continue
        fi
        ;;
    mmc*)
        MEDIA="card"
        FILESYSTEM=$(guess_fstype /dev/$PARTITION)
        INFO="MMC/SD: `cat /sys/block/$DRIVE/device/name`"
        ;;
    *)
        continue
        ;;
    esac
    echo "<Program label=\"${PARTITION}   ${FILESYSTEM}   ${INFO}\" icon=\"/usr/local/lib/X11/pixmaps/${MEDIA}48.png\">$HOME/.pup_event/drive_${PARTITION}/AppRun</Program>"
done < /proc/partitions
echo '</JWM>'
